<?php 
if(isset($_POST['submitted'])) {
		if(trim($_POST['contactName']) === '') {
			$nameError = 'Please enter your name.';
			$hasError = true;
		} else {
			$name = trim($_POST['contactName']);
		}
		
		if(trim($_POST['email']) === '')  {
			$emailError = 'Please enter your email address.';
			$hasError = true;
		} else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) {
			$emailError = 'You entered an invalid email address.';
			$hasError = true;
		} else {
			$email = trim($_POST['email']);
		}
			
		if(trim($_POST['comments']) === '') {
			$commentError = 'Please enter a message.';
			$hasError = true;
		} else {
			if(function_exists('stripslashes')) {
				$comments = stripslashes(trim($_POST['comments']));
			} else {
				$comments = trim($_POST['comments']);
			}
		}
			
		if(!isset($hasError)) {
			$emailTo = "youremail@mail.com";
			if (!isset($emailTo) || ($emailTo == '') ){
				$emailTo = "youremail@mail.com";
			}
			$subject = '[Contact Form] From '.$name;
			$body = "Name: $name \n\nEmail: $email \n\nComments: $comments";
			$headers = 'From: '.$name.' <'.$emailTo.'>' . "\r\n" . 'Reply-To: ' . $email;
			
			mail($emailTo, $subject, $body, $headers);
			$emailSent = true;
		}
	
} ?>

<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.validate/1.7/jquery.validate.min.js"></script> 

<?php $title= "Contact"; ?>
<?php
include_once('header.php');
?>
    
    <div id="the_body">
    
        <div class="container_12">
            
            <div class="grid_8" id="archive">
            	
                <div class="grid_8 alpha omega">
                
                    <div class="breadcrumb">
                    
                        <a href="index.php">Home</a> > Contact
                        
                    </div><!--breadcrumb-->
                    
                    <div class="description">
                    
                        <h1>Get in Touch</h1>
                         
                    </div><!--description-->
                    
                    <div class="clear"></div>
                    
                </div><!--grid_8 alpha omeg-->
            	
                <div class="grid_8 alpha omega">
                
                	<div id="content">
                        
                        <p>Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, 
                        ut fermentum massa justo sit amet risus. Nulla vitae elit libero, a pharetra augue.</p>

                        <?php if(isset($emailSent) && $emailSent == true) { ?>
            
                            <div class="thanks">
                                <p>Thanks, your email was sent successfully.</p>
                            </div>
        
                            <?php } else { ?>
                
                            <?php if(isset($hasError) || isset($captchaError)) { ?>
                                <p class="error">Sorry, an error occurred.<p>
                            <?php } ?>
            
                            <form action="#" id="contactForm" method="post">
                                
                                <p><label for="contactName">Name</label>
                                <input type="text" name="contactName" id="contactName" value="<?php if(isset($_POST['contactName'])) echo $_POST['contactName'];?>" class="required requiredField" />
                                </p>
                                <?php if($nameError != '') { ?>
                                    <span class="error"><?=$nameError;?></span> 
                                <?php } ?>
                        
                                <p>
                                 <?php if($emailError != '') { ?>
                                    <span class="error"><?=$emailError;?></span>
                                <?php } ?>
                                <label for="email">Email</label>
                                <input type="text" name="email" id="email" value="<?php if(isset($_POST['email']))  echo $_POST['email'];?>" class="required requiredField email" />
                               
                                </p>
                                
                        
                                <p><label for="commentsText">Message</label>
                                <textarea name="comments" id="commentsText" rows="10" cols="20" class="required requiredField"><?php if(isset($_POST['comments'])) { if(function_exists('stripslashes')) { echo stripslashes($_POST['comments']); } else { echo $_POST['comments']; } } ?></textarea></p>
                                <?php if($commentError != '') { ?>
                                    <span class="error"><?=$commentError;?></span> 
                                <?php } ?>
        
                        
        
                                <p><input type="hidden" name="submitted" id="submitted" value="true" />
                                
                                <p>
                                        
                                    <button class="btn" type="submit">Send Email</button>
                                    
                                </p>
        
                            </form>
                            
                        <?php } ?>
                        
                        <div class="clear"></div>
                    
                    </div><!--content-->

                </div><!--grid_8 alpha omega-->
        
            </div><!--grid_8-->
            
<?php
include_once('sidebar.php');
?>
    
            <div class="clear"></div>
            
        </div><!--container_12-->
    
    </div><!--the_body-->
    
<?php
include_once('footer.php');
?>